package com.wenbai.servicelightluxurystickers.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wenbai.servicelightluxurystickers.entity.StickForum;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StickForumMapper extends BaseMapper<StickForum> {
    List<StickForum> selectJoinUser();

    List<StickForum> selectForumPage(int startPage, int endPage);


    @Update("UPDATE stick_forum SET is_hot = CASE WHEN is_hot = 0 THEN 1 ELSE 0 END WHERE user_id = #{userId}")
    void setHot(StickForum stickForum, Long userId);

    @Select("SELECT * FROM stick_forum ORDER BY view_count DESC LIMIT 12")
    List<StickForum> hotSort();
}
